﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TextEditApp.Algorithm;

namespace TextEditApp.Forms
{
    public partial class CountResult : Form
    {
        public CountResult()
        {
            InitializeComponent();
        }

        private void CountResult_Load(object sender, EventArgs e)
        {
            Main mainForm = (Main)this.Owner;
            string text = mainForm.tbx_main.Text;
            SimpleDictionary d = SimpleDictionary.GetDictionary;
            var map = WordFrequency.GetWordFrequency(text, d);
            foreach(var m in map)
            {
                string row = string.Format("{0,-20}:{1,4}", m.Key, m.Value.cnt);
                if (!m.Value.is_en)
                {
                    row += "该词可能不是英文单词";
                }
                listBox1.Items.Add(row);
            }
        }
    }
}
